

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>agpy.kdist &mdash; agpy 0.1.2 documentation</title>
    
    <link rel="stylesheet" href="../../_static/extra.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '0.1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <link rel="top" title="agpy 0.1.2 documentation" href="../../index.html" />
    <link rel="up" title="agpy" href="../agpy.html" />
     
    <script type="text/javascript">

      var _gaq = _gaq || [];
      _gaq.push(['_setDomainName', 'pyspeckit.bitbucket.org']);
      _gaq.push(['_setAllowHash', false]);
      _gaq.push(['_trackPageview']);


    </script>
    <link rel="stylesheet" type="text/css" href="../../_static/extra.css" />
  </head>
  <body>
    <div class="header-wrapper">
      <div class="header">
        <h1><a href="../../index.html">agpy 0.1.2 documentation</a></h1>
        <div class="rel">
          <a href="http://agpy.googlecode.com">agpy Home </a>  |
          <a href=../../index.html>Docs Home </a>  |
          <a href="http://code.google.com/p/agpy/w/list">Wiki</a>  |
          <a href=../../search.html>Search </a>
        </div>
       </div>
    </div>

    <div class="content-wrapper">
      <div class="content">
        <div class="document">
            
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <h1>Source code for agpy.kdist</h1><div class="highlight"><pre>
<span class="k">try</span><span class="p">:</span> 
    <span class="kn">import</span> <span class="nn">coords</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
    <span class="k">print</span> <span class="s">&quot;Can&#39;t use kdist without the &#39;coords&#39; package&quot;</span>
<span class="kn">from</span> <span class="nn">numpy</span> <span class="kn">import</span> <span class="n">sqrt</span><span class="p">,</span> <span class="nb">abs</span><span class="p">,</span> <span class="n">pi</span><span class="p">,</span> <span class="n">cos</span><span class="p">,</span> <span class="n">sin</span><span class="p">,</span> <span class="nb">max</span><span class="p">,</span> <span class="n">ones</span><span class="p">,</span> <span class="n">array</span>

<div class="viewcode-block" id="kdist"><a class="viewcode-back" href="../../agpy.html#agpy.kdist.kdist">[docs]</a><span class="k">def</span> <span class="nf">kdist</span><span class="p">(</span><span class="n">l</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">vin</span><span class="p">,</span> <span class="n">near</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span><span class="n">r0</span><span class="o">=</span><span class="mf">8.4e3</span><span class="p">,</span><span class="n">v0</span><span class="o">=</span><span class="mf">2.54e2</span><span class="p">,</span><span class="n">dynamical</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
        <span class="n">kinematic</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span><span class="n">regular</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span><span class="n">rrgal</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span><span class="n">verbose</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
        <span class="n">inverse</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span><span class="n">silent</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">returnvtan</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">     NAME:</span>
<span class="sd">       KINDIST </span>
<span class="sd">     PURPOSE:</span>
<span class="sd">       To return the distance to an object given l,b,v</span>
<span class="sd">    </span>
<span class="sd">     CALLING SEQUENCE:</span>
<span class="sd">       dist = KDIST (L, B, V)</span>
<span class="sd">    </span>
<span class="sd">     INPUTS:</span>
<span class="sd">       L, B -- Galactic Longitude and Latitude (decimal degrees)</span>
<span class="sd">       V - Velocity w.r.t. LSR in km/s</span>
<span class="sd">     KEYWORD PARAMETERS:</span>
<span class="sd">       /NEAR, /FAR -- Report the near/far kinematic distances for Q1 and</span>
<span class="sd">                      Q4 data.</span>
<span class="sd">       RO, VO -- Force values for galactocentric distance for sun and</span>
<span class="sd">                 velocity of the LSR around the GC.  Default to 8.4 kpc</span>
<span class="sd">                 and 254 km/s (Reid et al., 2009)</span>
<span class="sd">       RGAL -- Named keyword containing galactocentric radius of sources.</span>
<span class="sd">       rrgal  - return galactocentric distance in addition to distance from us</span>
<span class="sd">       /DYNAMICAL -- Use the dynamical definition of the LSR</span>
<span class="sd">       /KINEMATIC -- Use the kinematic definition of the LSR (default)</span>
<span class="sd">       /REGULAR -- Do not apply the rotation correction for High mass</span>
<span class="sd">                   star forming regions.</span>
<span class="sd">        INVERSE -- If set, pass DISTANCE instead of velocity, and output is</span>
<span class="sd">                   velocity</span>
<span class="sd">        returnvtan - if set, return the tanent velocity and ignore the input</span>
<span class="sd">                    velocity</span>
<span class="sd">     OUTPUTS:</span>
<span class="sd">       DIST -- the kinematic distance in units of R0 (defaults to pc).</span>
<span class="sd">    </span>
<span class="sd">     MODIFICATION HISTORY:</span>
<span class="sd">    </span>
<span class="sd">           Fri Feb 27 00:47:18 2009, Erik &lt;eros@orthanc.local&gt;</span>
<span class="sd">    		 Adapted from kindist.pro</span>
<span class="sd">                 Translated from IDL to Python by Adam Ginsburg (adam.ginsburg@colorado.edu)</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">dtor</span> <span class="o">=</span> <span class="n">pi</span><span class="o">/</span><span class="mf">180.</span>

    <span class="k">if</span> <span class="n">regular</span><span class="p">:</span> <span class="n">vs</span> <span class="o">=</span> <span class="mf">0.0</span> 
    <span class="k">else</span><span class="p">:</span> <span class="n">vs</span><span class="o">=</span><span class="mf">15.0</span>

    <span class="k">if</span> <span class="n">kinematic</span> <span class="ow">or</span> <span class="ow">not</span><span class="p">(</span><span class="n">dynamical</span><span class="p">):</span>
        <span class="n">solarmotion_ra</span> <span class="o">=</span> <span class="p">((</span><span class="mi">18</span><span class="o">+</span><span class="mo">03</span><span class="o">/</span><span class="mf">6e1</span><span class="o">+</span><span class="mf">50.29</span><span class="o">/</span><span class="mf">3.6e3</span><span class="p">)</span><span class="o">*</span><span class="mi">15</span><span class="p">)</span>
        <span class="n">solarmotion_dec</span> <span class="o">=</span> <span class="p">(</span><span class="mi">30</span><span class="o">+</span><span class="mi">0</span><span class="o">/</span><span class="mf">6e1</span><span class="o">+</span><span class="mf">16.8</span><span class="o">/</span><span class="mf">3.6e3</span><span class="p">)</span>
        <span class="n">solarmotion_mag</span> <span class="o">=</span> <span class="mf">20.0</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">solarmotion_ra</span> <span class="o">=</span> <span class="p">((</span><span class="mi">17</span><span class="o">+</span><span class="mi">49</span><span class="o">/</span><span class="mf">6e1</span><span class="o">+</span><span class="mf">58.667</span><span class="o">/</span><span class="mf">3.6e3</span><span class="p">)</span><span class="o">*</span><span class="mi">15</span><span class="p">)</span>
        <span class="n">solarmotion_dec</span> <span class="o">=</span> <span class="p">(</span><span class="mi">28</span><span class="o">+</span><span class="mi">7</span><span class="o">/</span><span class="mf">6e1</span><span class="o">+</span><span class="mf">3.96</span><span class="o">/</span><span class="mf">3.6e3</span><span class="p">)</span>
        <span class="n">solarmotion_mag</span> <span class="o">=</span> <span class="mf">16.55294</span>

    <span class="n">cg</span> <span class="o">=</span> <span class="n">coords</span><span class="o">.</span><span class="n">Position</span><span class="p">((</span><span class="n">l</span><span class="p">,</span><span class="n">b</span><span class="p">),</span><span class="n">system</span><span class="o">=</span><span class="s">&#39;galactic&#39;</span><span class="p">)</span>
    <span class="n">solarmotion</span> <span class="o">=</span> <span class="n">coords</span><span class="o">.</span><span class="n">Position</span><span class="p">((</span><span class="n">solarmotion_ra</span><span class="p">,</span><span class="n">solarmotion_dec</span><span class="p">))</span>
    <span class="c">#  ra,dec = cg.j2000()</span>
    <span class="c">#  gcirc, 2, solarmotion_ra, solarmotion_dec, ra, dec, theta</span>
    <span class="n">theta</span> <span class="o">=</span> <span class="n">cg</span><span class="o">.</span><span class="n">angsep</span><span class="p">(</span><span class="n">solarmotion</span><span class="p">)</span><span class="o">.</span><span class="n">arcsec</span><span class="p">()</span>

    <span class="n">vhelio</span> <span class="o">=</span> <span class="n">vin</span><span class="o">-</span><span class="n">solarmotion_mag</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">theta</span><span class="o">/</span><span class="mf">206265.</span><span class="p">)</span>

    <span class="c"># UVW from Dehnen and Binney</span>
    <span class="n">bigu</span> <span class="o">=</span> <span class="mf">10.0</span>
    <span class="n">bigv</span> <span class="o">=</span> <span class="mf">5.23</span>
    <span class="n">bigw</span> <span class="o">=</span> <span class="mf">7.17</span>

    <span class="n">v</span> <span class="o">=</span> <span class="n">vhelio</span><span class="o">+</span><span class="p">(</span><span class="n">bigu</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span><span class="o">+</span><span class="n">bigv</span><span class="o">*</span><span class="n">sin</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">))</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">b</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span><span class="o">+</span><span class="n">bigw</span><span class="o">*</span><span class="n">sin</span><span class="p">(</span><span class="n">b</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span>

    <span class="c"># Compute tangent distance and velocity</span>
    <span class="n">rtan</span> <span class="o">=</span> <span class="n">r0</span><span class="o">*</span><span class="p">(</span><span class="n">cos</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">))</span><span class="o">/</span><span class="p">(</span><span class="n">cos</span><span class="p">(</span><span class="n">b</span><span class="o">*</span><span class="n">dtor</span><span class="p">))</span>
    <span class="n">vTEMP</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">sin</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span> <span class="o">-</span> <span class="n">v0</span><span class="o">/</span><span class="p">(</span><span class="n">v0</span><span class="o">-</span><span class="n">vs</span><span class="p">))</span> <span class="o">*</span> <span class="p">((</span><span class="n">v0</span><span class="o">-</span><span class="n">vs</span><span class="p">)</span><span class="o">*</span><span class="n">sin</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">b</span><span class="o">*</span><span class="n">dtor</span><span class="p">))</span>
    <span class="n">vhelioTEMP</span> <span class="o">=</span> <span class="n">vTEMP</span> <span class="o">-</span> <span class="p">((</span><span class="n">bigu</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span><span class="o">+</span><span class="n">bigv</span><span class="o">*</span><span class="n">sin</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">))</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">b</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span><span class="o">+</span><span class="n">bigw</span><span class="o">*</span><span class="n">sin</span><span class="p">(</span><span class="n">b</span><span class="o">*</span><span class="n">dtor</span><span class="p">))</span>
    <span class="n">vtan</span> <span class="o">=</span> <span class="n">vhelioTEMP</span><span class="o">+</span><span class="n">solarmotion_mag</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">theta</span><span class="o">/</span><span class="mf">206265.</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">returnvtan</span><span class="p">:</span>
        <span class="k">return</span> <span class="n">vtan</span>

    <span class="c"># This is r/r0</span>
    <span class="n">null</span> <span class="o">=</span> <span class="p">(</span><span class="n">v0</span><span class="o">/</span><span class="p">(</span><span class="n">v0</span><span class="o">-</span><span class="n">vs</span><span class="p">)</span><span class="o">+</span><span class="n">v</span><span class="o">/</span><span class="p">((</span><span class="n">v0</span><span class="o">-</span><span class="n">vs</span><span class="p">)</span><span class="o">*</span><span class="n">sin</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">b</span><span class="o">*</span><span class="n">dtor</span><span class="p">)))</span><span class="o">**</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>

    <span class="k">if</span> <span class="n">inverse</span><span class="p">:</span>
        <span class="n">radical</span> <span class="o">=</span> <span class="n">cos</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span> <span class="o">-</span> <span class="n">cos</span><span class="p">(</span><span class="n">b</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span> <span class="o">*</span> <span class="n">vin</span> <span class="o">/</span> <span class="n">r0</span> 
        <span class="n">null</span> <span class="o">=</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">cos</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span><span class="o">**</span><span class="mi">2</span> <span class="o">+</span> <span class="n">radical</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
        <span class="n">v</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="o">/</span><span class="n">null</span> <span class="o">-</span> <span class="n">v0</span><span class="o">/</span><span class="p">(</span><span class="n">v0</span><span class="o">-</span><span class="n">vs</span><span class="p">))</span> <span class="o">*</span> <span class="p">((</span><span class="n">v0</span><span class="o">-</span><span class="n">vs</span><span class="p">)</span><span class="o">*</span><span class="n">sin</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">b</span><span class="o">*</span><span class="n">dtor</span><span class="p">))</span>
        <span class="n">vhelio</span> <span class="o">=</span> <span class="n">v</span> <span class="o">-</span> <span class="p">((</span><span class="n">bigu</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span><span class="o">+</span><span class="n">bigv</span><span class="o">*</span><span class="n">sin</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">))</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">b</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span><span class="o">+</span><span class="n">bigw</span><span class="o">*</span><span class="n">sin</span><span class="p">(</span><span class="n">b</span><span class="o">*</span><span class="n">dtor</span><span class="p">))</span>
        <span class="n">vlsr</span> <span class="o">=</span> <span class="n">vhelio</span><span class="o">+</span><span class="n">solarmotion_mag</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span><span class="n">theta</span><span class="o">/</span><span class="mf">206265.</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">vlsr</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">vin</span> <span class="o">&gt;</span> <span class="n">vtan</span><span class="p">:</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">silent</span><span class="p">:</span>
                <span class="k">print</span> <span class="s">&quot;Velocity is greater than tangent velocity v=</span><span class="si">%f</span><span class="s">.  Returning tangent distance.&quot;</span> <span class="o">%</span> <span class="n">vtan</span>
            <span class="k">if</span> <span class="n">rrgal</span><span class="p">:</span> <span class="k">return</span> <span class="n">rtan</span><span class="p">,</span><span class="n">null</span><span class="o">*</span><span class="n">r0</span>
            <span class="k">return</span> <span class="n">rtan</span>
        <span class="c">#  The &gt; 0 traps things near the tangent point and sets them to the</span>
        <span class="c">#  tangent distance.  So quietly.  Perhaps this should pitch a flag?</span>
        <span class="n">radical</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">sqrt</span><span class="p">(((</span><span class="n">cos</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">))</span><span class="o">**</span><span class="mi">2</span><span class="o">-</span><span class="p">(</span><span class="mi">1</span><span class="o">-</span><span class="n">null</span><span class="o">**</span><span class="mi">2</span><span class="p">))</span> <span class="p">),</span><span class="mi">0</span><span class="p">)</span>

        <span class="n">fardist</span> <span class="o">=</span> <span class="n">r0</span><span class="o">*</span><span class="p">(</span><span class="n">cos</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span><span class="o">+</span><span class="n">radical</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="n">cos</span><span class="p">(</span><span class="n">b</span><span class="o">*</span><span class="n">dtor</span><span class="p">))</span>

        <span class="n">neardist</span> <span class="o">=</span> <span class="n">r0</span><span class="o">*</span><span class="p">(</span><span class="n">cos</span><span class="p">(</span><span class="n">l</span><span class="o">*</span><span class="n">dtor</span><span class="p">)</span><span class="o">-</span><span class="n">radical</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="n">cos</span><span class="p">(</span><span class="n">b</span><span class="o">*</span><span class="n">dtor</span><span class="p">))</span>

    <span class="n">rgal</span> <span class="o">=</span> <span class="n">null</span><span class="o">*</span><span class="n">r0</span>
    <span class="n">ind</span> <span class="o">=</span> <span class="p">(</span><span class="nb">abs</span><span class="p">(</span><span class="n">l</span><span class="o">-</span><span class="mi">180</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">90</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">ind</span><span class="o">.</span><span class="n">sum</span><span class="p">()</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span> <span class="n">neardist</span><span class="p">[</span><span class="n">ind</span><span class="p">]</span> <span class="o">=</span> <span class="n">fardist</span><span class="p">[</span><span class="n">ind</span><span class="p">]</span>
    <span class="k">elif</span> <span class="n">ind</span><span class="o">==</span><span class="bp">True</span><span class="p">:</span> <span class="n">neardist</span> <span class="o">=</span> <span class="n">fardist</span>

    <span class="k">if</span> <span class="ow">not</span><span class="p">(</span><span class="n">near</span><span class="p">):</span> <span class="n">dist</span> <span class="o">=</span> <span class="n">fardist</span>
    <span class="k">else</span><span class="p">:</span> <span class="n">dist</span> <span class="o">=</span> <span class="n">neardist</span>

    <span class="k">if</span> <span class="n">verbose</span><span class="p">:</span>
        <span class="k">print</span> <span class="s">&quot;radical: </span><span class="si">%f</span><span class="s">  null: </span><span class="si">%f</span><span class="s">  vin: </span><span class="si">%f</span><span class="s">  v: </span><span class="si">%f</span><span class="s">  vhelio: </span><span class="si">%f</span><span class="s"> rgal: </span><span class="si">%f</span><span class="s">  neardist: </span><span class="si">%f</span><span class="s">  fardist: </span><span class="si">%f</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">radical</span><span class="p">,</span><span class="n">null</span><span class="p">,</span><span class="n">vin</span><span class="p">,</span><span class="n">v</span><span class="p">,</span><span class="n">vhelio</span><span class="p">,</span><span class="n">rgal</span><span class="p">,</span><span class="n">neardist</span><span class="p">,</span><span class="n">fardist</span><span class="p">)</span>

    <span class="k">if</span> <span class="n">rrgal</span><span class="p">:</span> <span class="k">return</span> <span class="nb">abs</span><span class="p">(</span><span class="n">dist</span><span class="p">),</span><span class="nb">abs</span><span class="p">(</span><span class="n">rgal</span><span class="p">)</span>
    <span class="k">return</span> <span class="nb">abs</span><span class="p">(</span><span class="n">dist</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="vector_kdist"><a class="viewcode-back" href="../../agpy.html#agpy.kdist.vector_kdist">[docs]</a><span class="k">def</span> <span class="nf">vector_kdist</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">z</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>

    <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">z</span><span class="p">)</span><span class="o">==</span><span class="nb">type</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">type</span><span class="p">(</span><span class="n">z</span><span class="p">)</span><span class="o">==</span><span class="nb">type</span><span class="p">(</span><span class="mf">1.0</span><span class="p">):</span>
        <span class="n">z</span> <span class="o">=</span> <span class="n">z</span><span class="o">*</span><span class="n">ones</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
    <span class="n">v</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="k">for</span> <span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="n">k</span> <span class="ow">in</span> <span class="n">array</span><span class="p">([</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">z</span><span class="p">])</span><span class="o">.</span><span class="n">T</span><span class="p">:</span>
        <span class="n">v</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> <span class="n">kdist</span><span class="p">(</span><span class="n">i</span><span class="p">,</span><span class="n">j</span><span class="p">,</span><span class="n">k</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span> <span class="p">)</span>
    <span class="k">return</span> <span class="n">array</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="threekpcarm"><a class="viewcode-back" href="../../agpy.html#agpy.kdist.threekpcarm">[docs]</a><span class="k">def</span> <span class="nf">threekpcarm</span><span class="p">(</span><span class="n">longitude</span><span class="p">,</span><span class="n">radius</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span><span class="n">center_distance</span><span class="o">=</span><span class="mf">8.5</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">sqrt</span><span class="p">(</span><span class="n">radius</span><span class="o">**</span><span class="mi">2</span><span class="o">+</span><span class="n">center_distance</span><span class="o">**</span><span class="mi">2</span><span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="n">radius</span><span class="o">*</span><span class="n">center_distance</span><span class="o">*</span><span class="n">cos</span><span class="p">(</span> <span class="p">(</span><span class="mi">90</span><span class="o">-</span><span class="mi">3</span><span class="o">*</span><span class="n">longitude</span><span class="p">)</span> <span class="o">/</span> <span class="mf">180.</span> <span class="o">*</span> <span class="n">pi</span> <span class="p">))</span></div>
</pre></div>

          </div>
        </div>
      </div>
        </div>
        <div class="sidebar">
          <h3>Table Of Contents</h3>
          <ul>
<li class="toctree-l1"><a class="reference internal" href="../../agpy.html">Adam Ginsburg&#8217;s Python Code (agpy)</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../image_tools.html">Image Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../fft_tools.html">AG_fft_tools Package</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../plfit.html">plfit Package</a></li>
</ul>

          <h3 style="margin-top: 1.5em;">Search</h3>
          <form class="search" action="../../search.html" method="get">
            <input type="text" name="q" />
            <input type="submit" value="Go" />
            <input type="hidden" name="check_keywords" value="yes" />
            <input type="hidden" name="area" value="default" />
          </form>
          <p class="searchtip" style="font-size: 90%">
            Enter search terms or a module, class or function name.
          </p>
        </div>
        <div class="clearer"></div>
      </div>
    </div>

    <div class="footer">
      &copy; Copyright 2011, Adam Ginsburg.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.2pre.
    <script type="text/javascript">

      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-6253248-2']);
      _gaq.push(['_trackPageview']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();

    </script>
        
    </div>
  </body>
</html>